package com.sls.game.dao.impl.jpay;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.jpay.JpayAreaDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.jieyitong.JieyitongAreaServerInfo;

@Repository("jpayAreaDAO")
public class JpayAreaDAOImpl extends SuperDAO<JieyitongAreaServerInfo>
		implements JpayAreaDAO {

	@Override
	public void insert(JieyitongAreaServerInfo areaSrvInfo) {
		this.getSqlSession().insert(
				"mybatis.xml.JieyitongAreaSrvInfoMapper.insert", areaSrvInfo);

	}

	@Override
	public Pagination<JieyitongAreaServerInfo> queryPaginationList(
			JieyitongAreaServerInfo jInfo) {
		Pagination<JieyitongAreaServerInfo> paginationList = null;
		Integer rowCount = queryRowCount(jInfo);
		jInfo.calculate();
		List<JieyitongAreaServerInfo> list = queryJpayAreaInfoList(jInfo);
		paginationList = this.queryPagination(rowCount, list, jInfo);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(JieyitongAreaServerInfo jInfo) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.JieyitongAreaSrvInfoMapper.queryRowCount", jInfo);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<JieyitongAreaServerInfo> queryJpayAreaInfoList(
			JieyitongAreaServerInfo jInfo) {
		List<JieyitongAreaServerInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.JieyitongAreaSrvInfoMapper.queryJpayAreaInfoList",
				jInfo);
		return list;
	}

	@Override
	public JieyitongAreaServerInfo queryByGoodsIdAndAreaCode(
			JieyitongAreaServerInfo areaSrvInfo) {
		return this
				.getSqlSession()
				.selectOne(
						"mybatis.xml.JieyitongAreaSrvInfoMapper.queryByGoodsIdAndAreaCode",
						areaSrvInfo);
	}

	@Override
	public List<JieyitongAreaServerInfo> queryByGoodsId(String goodsId) {
		return this.getSqlSession().selectList(
				"mybatis.xml.JieyitongAreaSrvInfoMapper.queryByGoodsId",
				goodsId);
	}

	@Override
	public List<JieyitongAreaServerInfo> queryByGoodsIdAndAreaName(
			JieyitongAreaServerInfo areaSrvInfo) {
		return this
				.getSqlSession()
				.selectList(
						"mybatis.xml.JieyitongAreaSrvInfoMapper.queryByGoodsIdAndAreaName",
						areaSrvInfo);
	}

}
